package linkedlist.arrlist;

public class LinkedList {
    private Node firstNode;
    private Node lastNode;
    public <String> void insert(String data){
        Node node = new Node((java.lang.String) data);
        if(firstNode == null){
            firstNode=node;
            lastNode=node;
        }else {
            firstNode.setNext(node);
            lastNode=node;
        }
    }
    //打印节点
    public void printLinear(){
        printNode(firstNode);
    }
    public void printNode(Node node){
        System.out.println(firstNode.getData());
        Node nextNode=node.getNext();
        if(firstNode.getNext()!=null){
            printNode(nextNode);

        }
    }
}
